cmake_minimum_required(VERSION 3.15)

#xxxxxxxxxxxxxxxxxxx project root
project(poco_test LANGUAGES CXX)

# 强制 Debug 模式也使用 Release CRT
if(MSVC)
    foreach(flag CMAKE_CXX_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG)
        string(REPLACE "/MDd" "/MD" ${flag} "${${flag}}")
        string(REPLACE "/RTC1" "" ${flag} "${${flag}}")  # 移除运行时检查
    endforeach()
endif()

# ----- fmt lib
find_package(fmt CONFIG REQUIRED)
# find_package(spdlog REQUIRED)

add_compile_definitions(POCO_NO_AUTOMATIC_LIBS)
find_package(Poco CONFIG REQUIRED Foundation)

#=============== 试图修复 poco 没有 debug 库的问题
include(poco_fix_debug.cmake)

# =================== 测试 poco libs
set(MY_EXE test_poco)
add_executable(${MY_EXE}
    main.cpp
    TestThreadPool.h # 测试 thread pool
    TestTaskManger.h # 测试 poco task manager
)
target_include_directories(${MY_EXE}
    PRIVATE ${MY_COMMON_DIR}
)
target_link_libraries(${MY_EXE}
    PRIVATE Poco::Foundation
    # PRIVATE spdlog::spdlog
    fmt::fmt
)

# ----- 拷贝依赖的 DLL 到构建目录
my_cp_dlls(${MY_EXE})

# =================== Visual Studio 设置
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${MY_EXE})

# =================== 安装目标
# install(TARGETS
# ${mypy11} DESTINATION bin
# )

# 打印目标的宏定义
my_prt_target_definitions(${MY_EXE})

#============================= transform RelWithDebInfo -> Debug 配置
my_config_msvc_relwithdebinfo(${MY_EXE})